package com.peas.platform.module.icims.budget.project.api;

import com.peas.platform.common.core.dto.ResponseDto;
import com.peas.platform.module.icims.budget.project.api.req.SaveBudgetProjectTwoVo;
import com.peas.platform.module.icims.budget.project.api.req.SubmitBudgetProjectTwoVo;
import com.peas.platform.module.icims.budget.project.dto.BudgetProjectTwoDto;
import com.peas.platform.module.icims.budget.project.service.BudgetProjectTwoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

@Api(tags = "自定义接口-[预算控制]项目入库")
@RestController
@RequestMapping("/api/v1/customBudgetProject")
public class CustomBudgetProjectController {

    @Resource
    private BudgetProjectTwoService budgetProjectTwoService;

    @ApiOperation(value = "编辑暂存二级项目")
    @PostMapping("/stageBudgetProjectTwo")
    public ResponseDto<BudgetProjectTwoDto> stageBudgetProjectTwo(@RequestBody SaveBudgetProjectTwoVo vo) {
        BudgetProjectTwoDto dto = budgetProjectTwoService.saveBudgetProjectTwo(vo);
        return ResponseDto.getSuccessResponseDto(dto);
    }

    @ApiOperation(value = "编辑保存二级项目")
    @PostMapping("/saveBudgetProjectTwo")
    public ResponseDto<Boolean> saveBudgetProjectTwo(@RequestBody @Valid SaveBudgetProjectTwoVo vo) {
        budgetProjectTwoService.saveBudgetProjectTwo(vo);
        return ResponseDto.getSuccessResponseDto(true);
    }

    @ApiOperation(value = "编辑提交二级项目")
    @PostMapping("/submitBudgetProjectTwo")
    public ResponseDto<Boolean> submitBudgetProjectTwo(@RequestBody @Valid SubmitBudgetProjectTwoVo vo) {
        budgetProjectTwoService.submitBudgetProjectTwo(vo);
        return ResponseDto.getSuccessResponseDto(true);
    }

    @ApiOperation(value = "撤回二级项目")
    @PostMapping("/revocationBudgetProjectTwo/{id}")
    public ResponseDto<Boolean> revocationBudgetProjectTwo(@PathVariable("id") Long id) {
        budgetProjectTwoService.revocationBudgetProjectTwo(id);
        return ResponseDto.getSuccessResponseDto(true);
    }

    @ApiOperation(value = "同步二级项目到预算域")
    @PostMapping("/syncBudgetProjectTwo/{id}")
    public ResponseDto<Boolean> syncBudgetProjectTwo(@PathVariable(value = "id") Long id) {
        budgetProjectTwoService.syncBudgetProjectTwo(id);
        return ResponseDto.getSuccessResponseDto(true);
    }

}
